Passed
Push — master ( cc7767...b0feda )
by Stefan
11:56
created

XHR.js ➔ postXML   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 2
dl 0
loc 11
rs 9.95
c 0
b 0
f 0
1
/* 
2
 *******************************************************************************
3
 * Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 
4
 * and GN4-2 consortia
5
 *
6
 * License: see the web/copyright.php file in the file structure
7
 *******************************************************************************
8
 */
9
10
function postXML(funct, form) {
11
    var client = new XMLHttpRequest();
12
    client.onreadystatechange = funct;
13
    client.open("POST", form.action);
14
    client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
15
    var form_values = "";
16
    for (var i = 0; i < form.elements.length; i++) {
17
        form_values = form_values + (form_values === "" ? "" : "&") + encodeURIComponent(form.elements[i].name) + "=" + encodeURIComponent(form.elements[i].value);
18
    }
19
    client.send(form_values);
20
}
21